//
//  UIImage + Extension.swift
//  照片选择器
//
//  Created by 陈贵 on 15/9/26.
//  Copyright © 2015年 陈贵. All rights reserved.
//

import UIKit

extension UIImage{
    func getTheImage(image:UIImage,toWidth:CGFloat)-> UIImage {
        
        if toWidth > image.size.width {
            return image
        }
        let H = image.size.height / image.size.width * toWidth
        let size = CGSizeMake(toWidth, H)
        
        UIGraphicsBeginImageContext(size)
        drawInRect(CGRect(origin: CGPointZero
            , size: size))
        let getImage = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return getImage
        
    }

    
}
